package com.zch.single;

/**
 * 单例模式-饿汉式
 * 还未使用对象，对象就已经创建好了
 * 存在资源浪费问题
 */
public class SingleTon01 {
    public static void main(String[] args) {
        GirlFiend instance = GirlFiend.getInstance();
        System.out.println(instance);
    }
}

class GirlFiend {
    private final String name;

    private static final GirlFiend gf = new GirlFiend("小倩");

    private GirlFiend(String name) {
        this.name = name;
    }

    public static GirlFiend getInstance() {
        return gf;
    }

    @Override
    public String toString() {
        return "GirlFiend{" +
                "name='" + name + '\'' +
                '}';
    }
}
